<template>

  <div>

    <div style="display: flex; align-items: center; justify-content: space-between">
      <h3>部门统计</h3>
      <el-button type="primary" size="small" icon="el-icon-download" @click="handleExport">导出</el-button>
    </div>


    <el-table
      :data="dataList"
      border
      stripe
      style="width: 100%">
      <el-table-column
        prop="deptName"
        label="部门名称"/>
      <el-table-column
        prop="joinUser"
        label="考试人数"/>
      <el-table-column
        prop="passUser"
        label="通过人数"/>

      <el-table-column
        prop="passRate"
        label="通过率%"/>

      <el-table-column
        prop="avgScore"
        label="平均分"/>

    </el-table>

  </div>

</template>

<script>

import { statDeptScore, statDeptScoreExport } from '@/api/stat/exam'

export default {
  name: 'ExamStatDeptScore',
  props: {
    data: Object
  },
  data() {
    return {
      examList: [],
      dataList: []
    }
  },
  watch: {
    data: {
      handler() {
        this.fetchData()
      }
    }
  },

  created() {
    this.fetchData()
  },
  methods: {
    fetchData() {
      // 加载统计数据
      statDeptScore(this.data).then(res => {
        this.dataList = res.data
      })
    },
    // 导出数据
    handleExport() {
      statDeptScoreExport(this.data)
    }
  }
}
</script>

<style scoped>


</style>
